#ifndef __TIMER_H
#define __TIMER_H

#include "STC8G.H"
#include "basic.h"

// Realize a universal timer.

#define USE_12T_MODE 1



typedef enum
{
    TIMER0 = 0, // Default mode
    TIMER1,
   // TIMER2,
} timer_id_t;

/////////////The Timer Operation Parameter Description Types///////////////////////////
/////////////The Timer Operation Parameter Description Types///////////////////////////
/////////////The Timer Operation Parameter Description Types///////////////////////////

typedef struct
{
    // timer_mode_t timer_mode;
    // timer_id_t timer_id;//Be set by the programm
    uint16_t time;
    callback_t interrupt_cb;

    // Optional fields
    bool is_running;
} timer_handle_t;

///////////////////////////////////////////////////////////////
/*
the max time is 5,925 us(1T)
the min time is 65536 us(12T)

*/
timer_handle_t *timerInit(uint16_t us, callback_func_t func, void *user_param);
void timerStop(timer_handle_t *handle);

#endif
